const session = {}

const appName = process.env.APP_NAME

/**
 * @description 存储 storage 值
 * @param {String} name storage name
 * @param {String} value storage value
 * @param {Object} setting storage setting
 */
session.set = function (name = '', value = '') {
  return sessionStorage.setItem(`${appName}-${name}`, value)
}

/**
 * @description 拿到 storage 值
 * @param {String} name storage name
 */
session.get = function (name = '') {
  return sessionStorage.getItem(`${appName}-${name}`)
}

/**
 * @description 删除 storage
 * @param {String} name storage name
 */
session.remove = function (name = '') {
  return name ? sessionStorage.removeItem(`${appName}-${name}`) : sessionStorage.clear()
}

export default session
